package test;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ExecutionException;

/**
 * @Description TODO
 * @Author lxp
 * @Date 2022/9/29 下午3:46
 * @Version V1.0
 **/
public class AppFileUse {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        String old_date_publishedAt = "2023-11-12 16:07:38";
        String s = convertFormat(old_date_publishedAt, "yyyy-MM-dd HH:mm:ss", "yyyy-MM");

        System.out.println(s);
    }


    public static String convertFormat(String input, String fromFormat, String toFormat) {
        SimpleDateFormat formatter = new SimpleDateFormat(fromFormat);
        Date date = null;
        try {
            date = formatter.parse(input);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
        formatter = new SimpleDateFormat(toFormat);
        return formatter.format(date);
    }
}
